/**   
 * @Title: GetBeijingdanchangRecordDetailCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.lotteryrecord 
 * @Description: 获取北单购彩记录详情
 * @author: City Jiangsy@500wan.com   
 * @date: 2012-1-10 下午8:27:01  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.lotteryrecord;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.model.UserInfo;
import com.esun.model.beijingdanchang.BeidanHemaiDetailInfo;
import com.esun.model.beijingdanchang.BeidanHemaiDetailTeamInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: GetBeijingdanchangRecordDetailCommunicater
 * @Description: 获取北单购彩记录详情
 * @author: City Jiangsy@500wan.com
 * @date: 2012-1-10 下午8:27:01
 * 
 */
public class GetBeijingdanchangRecordDetailCommunicater extends ServerCommunicater {
	private String msgServer; // 服务器信息
	private boolean isSucceed = false;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	public boolean isGetDetailSucced(String programId) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_GET_LOTRECORD_DETAIL_BEIDAN));
		list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_LOTID, Config.BEIJINGZUQIUDANCHANG));
		list.add(mapItem(Key.KEY_PID, programId));
		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setMsgServer(super.getErrorMSG());
		if (super.getState() == 100) {
			isSucceed = true;
		} else {
			isSucceed = false;
		}
		return isSucceed;
	}

	public void updateDetailInfo() {
		BeidanHemaiDetailInfo hemaiinfo = BeidanHemaiDetailInfo.getBeidanHemaiDetailInfo();
		hemaiinfo.cleanAll();
		Hashtable<String, String> result = new Hashtable<String, String>();

		result = super.getResult();

		hemaiinfo.setUsername(result.get(Key.KEY_USERNAME));
		hemaiinfo.setAllmoney(result.get(Key.KEY_ALLMONEY));
		hemaiinfo.setBeishu(result.get(Key.KEY_BEISHU));
		hemaiinfo.setIshm(result.get(Key.KEY_ISHM));
		hemaiinfo.setAnumber(result.get(Key.KEY_ANUMBER));
		hemaiinfo.setLeftnumber(result.get(Key.KEY_LEFTNUMBER));
		hemaiinfo.setOnemoney(result.get(Key.KEY_ONEMONEY));
		hemaiinfo.setBaodimoney(result.get(Key.KEY_BAODIMONEY));
		hemaiinfo.setTicheng(result.get(Key.KEY_TICHENG));
		hemaiinfo.setIsmanyuan(result.get(Key.KEY_ISMANYUAN));
		hemaiinfo.setJindu(result.get(Key.KEY_RENQI));
		hemaiinfo.setLotterycount(result.get(Key.KEY_LOTTERYCOUNT));
		hemaiinfo.setProid(result.get(Key.KEY_PROID));
		hemaiinfo.setPlayid(result.get(Key.KEY_PLAYID));
		hemaiinfo.setPlayname(result.get(Key.KEY_PLAYNAME));
		hemaiinfo.setLotterymonery(result.get(Key.KEY_LOTTERYMONERY));
		hemaiinfo.setAddtime(result.get(Key.KEY_ADDTIME));
		hemaiinfo.setIssuc(result.get(Key.KEY_ISSUC));
		hemaiinfo.setFileorcode(result.get(Key.KEY_FILEORCODE));
		hemaiinfo.setIsUpload(result.get(Key.KEY_ISUPLOAD));
		hemaiinfo.setIsshow(result.get(Key.KEY_ISSHOW));
		hemaiinfo.setNfileorcode(result.get(Key.KEY_NFILEORCODE));
		hemaiinfo.setDanma(result.get(Key.KEY_DANMA));
		hemaiinfo.setGgtypename(result.get(Key.KEY_GGTYPENAME));
		hemaiinfo.setGggroup(result.get(Key.KEY_GGGROUP));
		hemaiinfo.setGetmoney(result.get(Key.KEY_GETMONEY));
		hemaiinfo.setLotterystate(result.get(Key.KEY_LOTTERYSTATE));
		hemaiinfo.setZhanji_jinpai(result.get(Key.KEY_ZHANJI_JINPAI));
		hemaiinfo.setZhanji_yinpai(result.get(Key.KEY_ZHANJI_YINPAI));
		hemaiinfo.setGoldDiamond(result.get(Key.KEY_ZHANJI_JINZUAN));
		hemaiinfo.setSilverDiamond(result.get(Key.KEY_ZHANJI_YINZUAN));
		hemaiinfo.setGoldStar(result.get(Key.KEY_ZHANJI_JINXING));
		hemaiinfo.setSilverStar(result.get(Key.KEY_ZHANJI_YINXING));
		hemaiinfo.setGoldCup(result.get(Key.KEY_ZHANJI_JINBEI));
		hemaiinfo.setExpect(Key.KEY_EXPECT);
		hemaiinfo.setBaodi(result.get(Key.KEY_BAODI));
		ArrayList<BeidanHemaiDetailTeamInfo> teamList = new ArrayList<BeidanHemaiDetailTeamInfo>();
		ArrayList<Hashtable<String, String>> resultList = new ArrayList<Hashtable<String, String>>();
		resultList = super.getListResult();
		for (int i = 0; i < super.getListResult().size(); i++) {

			Hashtable<String, String> listItem = new Hashtable<String, String>();
			listItem = resultList.get(i);

			BeidanHemaiDetailTeamInfo beidanHemaiDetailTeamInfo = new BeidanHemaiDetailTeamInfo();
			beidanHemaiDetailTeamInfo.setGuestteamname(listItem.get(Key.KEY_GUESTTEAMNAME));
			beidanHemaiDetailTeamInfo.setHometeamname(listItem.get(Key.KEY_HOMETEAMNAME));
			beidanHemaiDetailTeamInfo.setIsdm(listItem.get(Key.KEY_ISDM));
			beidanHemaiDetailTeamInfo.setLeaguematchname(listItem.get(Key.KEY_LEAGUEMATCHNAME));
			beidanHemaiDetailTeamInfo.setOrdernum(listItem.get(Key.KEY_ORDERNUM));
			beidanHemaiDetailTeamInfo.setRangqiu(listItem.get(Key.KEY_RANGQIU));
			beidanHemaiDetailTeamInfo.setShotin(listItem.get(Key.KEY_SHOTIN));
			beidanHemaiDetailTeamInfo.setResultspf(listItem.get(Key.KEY_RESULTSPF));
			teamList.add(beidanHemaiDetailTeamInfo);
		}
		hemaiinfo.setTeamList(teamList);

	}

	/**
	 * @Title: mapItem
	 * @Description: (工具类,用于构建AraayList单条内容)
	 * @param @param name 参数名
	 * @param @param value 参数值
	 * @param @return map
	 * @return HashMap<String,String> 返回类型
	 * @throws
	 */
	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
